//
//  NewsTableViewCell.m
//  xpkc
//
//  Created by TopSage iOS on 14/12/19.
//  Copyright (c) 2014年 _YanLu_. All rights reserved.
//

#import "NewsTableViewCell.h"

@implementation NewsTableViewCell

- (void)awakeFromNib {
    // Initialization code
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //
        [self creatNewsCell];
    }
    return self;
}
-(void)creatNewsCell{
    /**
     左侧图片
     */
    _newsImg=[[UIImageView alloc] initWithFrame:RECT(15, 10, 120, 80)];
    /**
     题目
     */
    _newsTitle=[[UILabel alloc]initWithFrame:RECT(_newsImg.frame.origin.x+125, 0, SCREEN_WIDTH-145, 40)];
    _newsTitle.backgroundColor=CCOLOR;
    _newsTitle.font = [UIFont systemFontOfSize:16.0f];
    _newsTitle.numberOfLines=2;
    /**
     新闻内容
     */
    _newsContent=[[UILabel alloc]initWithFrame:RECT(_newsImg.frame.origin.x+125, _newsTitle.frame.origin.y+30, SCREEN_WIDTH-150, 45)];
    _newsContent.backgroundColor=CCOLOR;
    _newsContent.font=FONT_SYS_LITTLE;
    _newsContent.numberOfLines=0;
    _newsContent.textColor = RGBCOLOR(134, 129, 135);
    /**
     日期
     */
    _newsDate=[[UILabel alloc]initWithFrame:RECT(_newsImg.frame.origin.x+125, _newsContent.frame.origin.y+38, SCREEN_WIDTH-130, 30)];
    _newsDate.backgroundColor=CCOLOR;
    _newsDate.font=FONT_SYS_LITTLE;
    _newsDate.textColor = RGBCOLOR(134, 129, 135);
    /**
     是否推荐
     */
    _newsRecommend=[[UIImageView alloc]initWithFrame:RECT(SCREEN_WIDTH-140, _newsContent.frame.origin.y+42+5, 20, 14)];
    /**
     是否热门
     */
    _newsHot=[[UIImageView alloc]initWithFrame:RECT(SCREEN_WIDTH-110, _newsContent.frame.origin.y+42+5, 20, 14)];
    /**
     浏览次数
     */
    _newsBrowse=[[UILabel alloc]initWithFrame:RECT(SCREEN_WIDTH-80, _newsContent.frame.origin.y+38, 70, 30)];
    _newsBrowse.backgroundColor=CCOLOR;
    _newsBrowse.font=FONT_SYS_LITTLE;
    _newsBrowse.textColor = RGBCOLOR(134, 129, 135);
    
    [self addSubview:_newsImg];
    [self addSubview:_newsTitle];
    [self addSubview:_newsContent];
    [self addSubview:_newsDate];
    [self addSubview:_newsRecommend];
    [self addSubview:_newsHot];
    [self addSubview:_newsBrowse];
    
}
- (void)setHadImg:(BOOL)hadImg{
    if (hadImg) {
        _newsImg.hidden = NO;
        _newsTitle.frame = RECT(_newsImg.frame.origin.x+125, 0, SCREEN_WIDTH-145, 40);
        _newsContent.frame = RECT(_newsImg.frame.origin.x+125, _newsTitle.frame.origin.y+30, SCREEN_WIDTH-150, 45);
    }else{
        _newsImg.hidden = YES;
        _newsTitle.frame = RECT(15, 0, SCREEN_WIDTH-30, 40);
        _newsContent.frame = RECT(15, _newsTitle.frame.origin.y+30, SCREEN_WIDTH-30, 45);
    }
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
